package com.lehecai.core.api.credit;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by pc on 14-2-24.
 */
public class GoodsClassesType extends IntegerBeanLabelItem {

    private static final long serialVersionUID = 5959923813363953416L;
    private static final Logger logger = LoggerFactory.getLogger(GoodsClassesType.class.getName());

    private static List<GoodsClassesType> _items = new ArrayList<GoodsClassesType>();
    private static List<GoodsClassesType> items;

    protected GoodsClassesType(String name, int value) {
        super(GoodsClassesType.class.getName(), name, value);
        _items.add(this);
    }

    public static GoodsClassesType getItem(int value){
        try {
            return (GoodsClassesType) GoodsClassesType.getResult(GoodsClassesType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    /**
     * @return 所有商品类型
     */
    public static List<GoodsClassesType> getItems() {
        return items;
    }

    public static final GoodsClassesType ALL = new GoodsClassesType("全部", -1);
    public static final GoodsClassesType GIFT_EXCHANGE = new GoodsClassesType("礼品兑换", 1);
    public static final GoodsClassesType LOTTERY_SERVICE = new GoodsClassesType("乐彩服务", 2);

    static {
        synchronized (_items) {
            items = Collections.unmodifiableList(_items);
        }
    }

}
